<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    function duixiang(str){
        let arrstr=str.split('&')//把字符串按照&符分割
         let obj={}//定义一个空对象
         for(let i=0;i<arrstr.length;i++){//循环遍历分割完成以后的字符串
            //console.log(arrstr[i]);
            let strry=arrstr[i].split('=')//在把分割完成以后的两个字符串按着=分割
            //console.log(strry);
            obj[strry[0]]=strry[1]//对象的键值等于字符串的第一个下标
         }
         console.log(obj);
        
        //console.log(arrstr);
      

    }
    duixiang('name=adimin&password=123456')

    
</script>